<script lang="ts">
import Trumpet from '~/assets/imgs/notify-trumpet.png';

export enum TtNotifyType {
  USER,
  PLATEFORM,
}
</script>

<script lang="ts" setup>
const props = defineProps<{
  title: string;
  message: string;
  type: TtNotifyType;
}>();

const emits = defineEmits<{
  close: [];
}>();

const typeClass = computed(() => props.type === TtNotifyType.PLATEFORM ? 'tt-sys-notify' : 'tt-user-notify');
</script>

<template>
  <div
    class="min-h-18 w-80 cursor-pointer rounded-4 bg-gradient-to-r p-2"
    :class="[typeClass]"
    @click="emits('close')"
  >
    <div class="flex-start items-start gap-3">
      <img :src="Trumpet" class="ml-1 mt-1 h-8.5 w-8.5">
      <div class="w-55 flex flex-col gap-1">
        <div
          v-if="props.type === TtNotifyType.PLATEFORM"
          class="line-clamp-1 text-base font-bold"
        >
          {{ props.title }}
        </div>
        <div class="line-clamp-3 text-sm">
          <template v-if="props.type === TtNotifyType.PLATEFORM">
            <div v-html="props.message" />
          </template>
          <template v-else>
            {{ props.title }}
          </template>
        </div>
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
/** 系统通知样式 */
.tt-sys-notify {
  --uno: 'from-[#242528] to-[#000] text-white';
}

/** 用户通知样式 */
.tt-user-notify {
  --uno: 'from-[#242528] to-[#000] text-white';
}

:global(.ant-notification-notice.tt-notification) {
  width: fit-content;
  padding: 0;
  margin-right: -24px;
  overflow: initial;
  background: none;
}

:global(.ant-notification-notice.tt-notification .ant-notification-notice-message) {
  display: none;
}

:global(.ant-notification-notice.tt-notification .ant-notification-notice-close) {
  top: 8px;
  right: 8px;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 25px;
  height: 25px;
  color: white;
  //background: theme('colors.sys.layer.b');
  background: transparent;
  box-shadow: 0 0 5px 0 rgb(0 0 0 / 0%);
}

:global(.ant-notification-notice.tt-notification .ant-notification-notice-close:hover) {
  background: transparent;
}

:global(.ant-notification-notice.tt-notification .ant-notification-close-x) {
  display: block;
  width: 14px;
  height: 14px;
  font-size: 14px;
  line-height: 1em;
}
:global(.ant-notification-notice.tt-notification .ant-notification-close-x .ant-notification-close-icon) {
  font-size: 16px;
  font-weight: 600;
}
</style>
